<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <p>
        编写函数，判断一个字符串的内容是不是纯数字
    </p>
    <input type="text" placeholder="请输入文本">
    <input type="button" value="计算" onclick="getResult()">
    <span id="span"></span>
    <script>
        function getResult() {
            let str = document.querySelector('input').value;
            let res;
            Number(str) ? res = '纯数字' : res = '内容不纯';
            document.getElementById('span').innerHTML = res;
        }
    </script>
</body>

</html>